<?php
try{
	include '../ini.php';
    include '../classes/xl_comment.php';
    $dt_xl_comment=new xl_comment;
    if(isset($_GET['id'])){
        $read=$dt_xl_comment->read_id($_GET['id']);
        if($read === FALSE){
            throw new Exception('Mã này không tồn tại trên url');
        }
        if($_GET['id'] != $read['id']){
            $_GET['id']=$dt_xl_admin->removeSQLI($_GET['id']);
            header("Location: comment_list.php?id=".$_GET['id']);
        }
    }
    $list_comment=$dt_xl_comment->read();
    
    $dt_smarty->assign('list_comment',$list_comment);
	$contenForLayout=$dt_smarty->fetch('product/comment_list.tpl');
	$dt_smarty->assign('contenForLayout',$contenForLayout);
	$dt_smarty->assign('titleForLayout','Danh sách ý kiến');
	$dt_smarty->display('layout/defaults.tpl');
    $dbh=NULL;
	
} catch(Exception $e){
    $_SESSION['msg']=$e->getMessage();
	$_SESSION['type_msg']='error';
    if(empty($_SERVER['HTTP_REFERER'])){
        header('Location: comment_list.php');
    }else{
        header('Location:'.$_SERVER['HTTP_REFERER']);
    }
    $dbh=NULL;

}